package com.yh.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.service.userService;
import com.yh.bean.PageBean;
import com.yh.service.impl.userServiceImpl;

/**
 * Servlet implementation class TextServlet2
 */
@WebServlet("/Loginservlet")
public class Loginservlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Loginservlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		String username=request.getParameter("userName");
		//get提交方式解决中文乱码
		username=new String(username.getBytes("ISO-8859-1"),"UTF-8");			
		String pwd=request.getParameter("pwd");
         if(username!=null&&pwd!=null){
        	 if (username.equals("尤献吻")&&"11111".equals(pwd)) {
				response.sendRedirect("TextServlet2");
			}else{
				response.sendRedirect("login.jsp");
			}
         }
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	  System.out.println("doPost----------------------");
	  doGet(request, response);
	}

}